﻿#pragma once
#include "common.h"

// 饿汉模式
class centralCache {
public:
	static centralCache* getCentralCache() {
		return &_cInit;
	}

	// 获取一个非空的span
	span* getOneSpan(spanList& list, size_t byte_size);
	
	// 从中心缓存获取一定数量的对象给thread cache
	size_t fetchOfCentral(void*& start, void*& end, size_t nPage, size_t index, size_t alignNum);

	// 接收从threadCache返回的内存块
	void releaseThreadCacche(void* start, size_t n);

	
private:
	centralCache() {}

	centralCache(const centralCache& c) = delete;
	void operator=(const centralCache& c) = delete;

private:
	spanList _centralSpanList[MAX_BUCKET];

	static centralCache _cInit;
};